$( document ).bind( "mobileinit", function() {
    $.support.cors                 = true;
    $.mobile.allowCrossDomainPages = true;
    $.mobile.pushStateEnabled      = false;    
    window.setInterval("getStatisticList()", 10000);
});

$('#storylistpage').bind('pageinit', function(event) {
	getStatisticList();
});

function getStatisticList() {
    $.mobile.showPageLoadingMsg();    
    $.jsonp({
        cache:false,
        callback: 'slopetracker',
        url: mbapp.serviceURL + 'getstats',
        success: function (json, textStatus, xOptions) {
          $('#storylist li').remove();      
            mbapp.stats = json.result;
            $.each(mbapp.stats, function(index, item) {
                    $('#storylist').append('<li><h4>' + item.key_title + ': <span style="color:blue;">' + item.key_value + '</span></h4></li>');
            });
            $('#storylist').listview('refresh');
        },
        complete: function(xOptions, textStatus){
            $.mobile.hidePageLoadingMsg();
        },
        error: function (xOptions, textStatus) {
        }
    });
}